package com.example.taobaou.base;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getResId());
        /**
         * 如何设置灰色UI
         */
//        ColorMatrix cm = new ColorMatrix();  获取颜色矩阵
//        cm.setSaturation(0);                 设置颜色为灰色，0灰色 1原色
//        Paint paint = new Paint();           获取画笔
//        paint.setColorFilter(new ColorMatrixColorFilter(cm));    画笔设置颜色为灰色
//        View decorView = getWindow().getDecorView();             获取当前整个窗口的顶级视图（getDecorView:这个方法是获取顶级视图）
//        decorView.setLayerType(View.LAYER_TYPE_SOFTWARE,paint);  设置当前整个窗口的颜色为灰色
        initView();
        initEvent();
        initPresenter();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.release();
    }

    protected void release() {

    }

    protected abstract void initPresenter();

    //绑定布局
    protected abstract int getResId();

    //监听事件
    protected void initEvent() {

    }

    //绑定控件
    protected abstract void initView();

    //跳转页面
    protected void goTo(Class cls){
        startActivity(new Intent(BaseApplcation.getAppContext(),cls));
    }
}
